﻿#region Imports
using System;
using System.ComponentModel;
using CommonUtilities.Attributes;
using CommonUtilities.Extensions;
#endregion

namespace DirectoryAnalyzer.Models
{
    [Serializable]
    public class FileCategory
    {
        #region Properties
        [Unique]
        [Sortable]
        [DisplayName("Category")]
        public string FileType { get; set; }

        [Sortable]
        [DisplayName("Size (bytes)")]
        public long ByteSize { get; set; }

        [DisplayName("Total size")]
        public string TypeSize { get { return ByteSize.ToPracticalSize(); } }

        [Sortable]
        [DisplayName("# files")]
        public long FileCount { get; private set; }

        [DisplayName("Avg. size per file (B)")]
        public string AvgFileSize { get { return (FileCount == 0 ? 0 : ByteSize / FileCount).ToPracticalSize(); } }

        [Browsable(false)]
        public long Sort { get; set; }
        #endregion

        #region Constructors
        public FileCategory()
        {
            ;
        }

        public FileCategory(string fileType, long byteSize, long sort, long fileCount)
        {
            FileType = fileType;
            ByteSize = byteSize;
            FileCount = fileCount;
            Sort = sort;
        }
        #endregion
    }
}
